package Class;
import java.util.Scanner;

public class CourseSelectionSystem {
    private static void Loginmenu() {
        System.out.println("Welcome to the Course Selection System!！" + "\n" + "菜单：" + "\n" + "1.教师登录" +
                "\n" + "2.学生登陆" + "\n" + "请输入1/2选择登陆方式");
    }

    private static void menu2() {
        System.out.println("Welcome to the Course Selection System!" + "\n" + "菜单：" + "\n" + "1.选课操作" + "\n" + "2.退课操作" + "\n" + "请输入1/2选择操作类型");
    }

    private static void reportError() {
        System.out.println("您的输入有误，程序已终止");
    }

    private static void fengexian() {
        for (int i = 1; i <= 10; i++) {
            System.out.print("/////");
        }
        ;
        System.out.println();
    }

    public static void main(String[] args) { //程序入口
        // CourseSelectionSystem TS = new CourseSelectionSystem();
        Scanner input = new Scanner(System.in);
        Curriculums gaoshu = new Curriculums(1, "gaoshu", "jiao101", "8:00"); //创建课程类实例对象
        Curriculums wuli = new Curriculums(2, "wuli", "jiao106", "13:00");
        Curriculums dianlu = new Curriculums(3, "dianlu", "jiao201", "14:00");
        Curriculums xiandai = new Curriculums(4, "xiandai", "jiao202", "15:00");
        Curriculums lisan = new Curriculums(5, "lisan", "jiao203", "16:00");
        Curriculums wulishiyan = new Curriculums(6, "wulishiyan", "jiao204", "17:00");
        Curriculums moren1[] = new Curriculums[6];
        Curriculums moren2[] = new Curriculums[6];
        Teachers MrFeng = new Teachers(1, "MrFeng", "男", moren1); //创建教师类实例对象
        Students StdLi = new Students(1, "StdLi", "男", moren2); //创建学生类实例对象
        int x = 0;
        while (true) {
            CourseSelectionSystem.fengexian();
            if (x == 0) {
                System.out.println("欢迎使用学生选课系统" + "\n" + "还未有教师开设课程，本次默认为开课操作" + "\n" + "正在进行开课操作!");
                CourseSelectionSystem.fengexian();
                System.out.println("可开课程为:" + "\n" + gaoshu.curriculumsname + "\n" + wuli.curriculumsname + "\n"
                        + dianlu.curriculumsname + "\n" + xiandai.curriculumsname + "\n" + lisan.curriculumsname + "\n"
                        + wulishiyan.curriculumsname + "以上次序依次为0~5");
                CourseSelectionSystem.fengexian();
                System.out.println("请输入所开设课程");
                int z = input.nextInt();
                Curriculums moren[] = {gaoshu, wuli, dianlu, xiandai, lisan, wulishiyan};
                MrFeng.openCurriculums(MrFeng, z, moren[z]);
                moren[z].curriculumsTeacher = "MrFeng";
                CourseSelectionSystem.fengexian();
                System.out.println("是否继续进行操作?" + "\n" + "1.继续" + "\n" + "2.结束");
                CourseSelectionSystem.fengexian();
                x = input.nextInt();
                if (x == 1) {
                    continue;
                }
                CourseSelectionSystem.fengexian();
                break;
            } else {
                CourseSelectionSystem.Loginmenu();
                CourseSelectionSystem.fengexian();
                x = input.nextInt();
                if (x == 1) { //教师开课操作
                    System.out.println("正在进行开课操作!");
                    CourseSelectionSystem.fengexian();
                    System.out.println("可开课程为:" + "\n" + gaoshu.curriculumsname + "\n" + wuli.curriculumsname + "\n"
                            + dianlu.curriculumsname + "\n" + xiandai.curriculumsname + "\n" + lisan.curriculumsname
                            + "\n" + wulishiyan.curriculumsname + "以上次序依次为0~5");
                    CourseSelectionSystem.fengexian();
                    System.out.println("请输入所开设课程");
                    int z = input.nextInt();
                    Curriculums moren[] = {gaoshu, wuli, dianlu, xiandai, lisan, wulishiyan};
                    MrFeng.openCurriculums(MrFeng, z, moren[z]);
                    moren[z].curriculumsTeacher = "MrFeng";
                } else if (x == 2) {
                    CourseSelectionSystem.fengexian();
                    CourseSelectionSystem.menu2();
                    CourseSelectionSystem.fengexian();
                    int s = input.nextInt();
                    if (s == 1) { //学生选课操作
                        CourseSelectionSystem.fengexian();
                        System.out.println("正在进行选课操作!");
                        CourseSelectionSystem.fengexian();
                        System.out.println("可开课程为:" + "\n" + gaoshu.curriculumsname + "\n" + wuli.curriculumsname + "\n"
                                + dianlu.curriculumsname + "\n" + xiandai.curriculumsname + "\n" + lisan.curriculumsname
                                + "\n" + wulishiyan.curriculumsname + "以上次序依次为0~5");
                        CourseSelectionSystem.fengexian();
                        Curriculums moren[] = {gaoshu, wuli, dianlu, xiandai, lisan, wulishiyan};
                        int j = input.nextInt();
                        StdLi.choiceCurriculums(StdLi, j, moren[j]);
                    } else if (s == 2) { //学生退课操作
                        System.out.println("正在进行退课操作!");
                        CourseSelectionSystem.fengexian();
                        int p = input.nextInt();
                        StdLi.outCurriculums(StdLi, p);
                    } else {
                        CourseSelectionSystem.fengexian();
                        CourseSelectionSystem.reportError();
                        CourseSelectionSystem.fengexian();
                        break;
                    }
                    CourseSelectionSystem.fengexian();
                    System.out.println("本次选课已结束，正在打印学生选课信息"); //课表打印
                    System.out.println("学生姓名:" + StdLi.name + "\n" + "所选课程:" + "\n");
                    for (int i = 0; i < 6; i++) {
                        if (StdLi.curriculums[i] == null) {
                            continue;
                        }
                        System.out.print(StdLi.curriculums[i].number + "丨" + StdLi.curriculums[i].curriculumsname
                                + "丨" + StdLi.curriculums[i].place + "丨" + StdLi.curriculums[i].Classtime + "丨"
                                + StdLi.curriculums[i].curriculumsTeacher + "\n");
                    }
                    CourseSelectionSystem.fengexian();
                } else {
                    CourseSelectionSystem.fengexian();
                    CourseSelectionSystem.reportError();
                    CourseSelectionSystem.fengexian();
                    break;
                }
            }
            ;
            System.out.println("是否继续进行操作?" + "\n" + "1.继续" + "\n" + "2.结束"); //控制系统循环
            CourseSelectionSystem.fengexian();
            int y = input.nextInt();
            if (y == 1) {
                continue;
            } else if (y == 2)
                break;
            else {
                CourseSelectionSystem.fengexian();
                CourseSelectionSystem.reportError();
                CourseSelectionSystem.fengexian();
                break;
            }
        }
        input.close();
    }
}